/**
 * 
 */
package com.mvc.utils;

/**
 * @author qingjie
 *
 */
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

/**
 * 
 * Date: 14-9-1
 * Time:下午4:12
 */
public class FileUpload {

	 public static final String FILE_PATH = "c:/bxds/upload/";

	    //文件上传
	    public static String uploadFile(MultipartFile file, HttpServletRequest request,String fileName) throws IOException {
	        File tempFile = new File(FILE_PATH,String.valueOf(fileName));
	        if (!tempFile.getParentFile().exists()) {
	            tempFile.getParentFile().mkdir();
	        }
	        if (!tempFile.exists()) {
	            tempFile.createNewFile();
	        }
	        file.transferTo(tempFile);
	        return tempFile.getName();
	    }

	    public static File getFile(String fileName) {
	        return new File(FILE_PATH, fileName);
	    }
}